﻿#pragma once

#include "../../Server/MirEnvir/Envir.h"
#include "Control/MapContainer.h"
#include <vector>
#include <stdexcept>
#include <any>
#include "../../stringhelper.h"

using namespace Server::MirForms::VisualMapInfo::Class;
using namespace Server::MirForms::VisualMapInfo::Control;
using namespace Microsoft::VisualBasic::PowerPacks;
using namespace Server::MirEnvir;
using namespace Server::MirDatabase;

namespace Server::MirForms::VisualMapInfo
{
    class VForm : public System::Windows::Forms::Form
    {
    private:
        ShapeContainer *Canvas = new ShapeContainer();

    public:
        virtual ~VForm()
        {
            delete Canvas;
            delete MouseDownLocation;
            delete components;
            delete Tool;
            delete SelectButton;
            delete AddButton;
            delete MoveButton;
            delete ResizeButton;
            delete mapContainer1;
            delete MapImage;
            delete splitter1;
            delete toolStripLabel1;
            delete tabPage2;
            delete RespawnPanel;
            delete RespawnTools;
            delete tabPage4;
            delete MiningPanel;
            delete toolStrip2;
            delete MiningSelectAll;
            delete MiningSelectNone;
            delete RegionTabs;
            delete toolStrip1;
            delete MiningRemoveSelected;
            delete MiningHideRegion;
            delete MiningShowRegion;
            delete MiningFocusRegion;
            delete MiningInvertSelection;
            delete toolStripSeparator1;
            delete MiningFilter;
            delete EndFocus;
            delete FocusBreak;
            delete statusStrip1;
            delete MapDetailsLabel;
            delete toolStrip3;
            delete RespawnsRemoveSelected;
            delete ResapwnsHideRegion;
            delete ResapwnsShowRegion;
            delete toolStripSeparator2;
            delete ResapwnsFocusRegion;
            delete RespawnsFilter;
            delete RespawnsInvertSelection;
            delete RespawnsSelectAll;
            delete RespawnsSelectNone;
        }

        Server::MirEnvir::Envir *getEnvir() const;

        Point *MouseDownLocation;

        VForm();

    private:
        void VForm_Load(std::any sender, EventArgs *e);

        void VForm_FormClosing(std::any sender, FormClosingEventArgs *e);

        void InitializeMap();

        void InitializeMineInfo();

        void InitializeRespawnInfo();

        void RedrawMap();

        void FocusModeActivated(std::any sender, EventArgs *e);

        void ToolSelectedChanged(std::any sender, EventArgs *e);

        void EndFocus_Click(std::any sender, EventArgs *e);

        void MapImage_Click(std::any sender, EventArgs *e);

        void RegionTabs_SelectedIndexChanged(std::any sender, EventArgs *e);

        void MapImage_MouseDown(std::any sender, MouseEventArgs *e);

    protected:
        CreateParams *getCreateParams() const override;

        // Quick Keys
        bool ProcessCmdKey(Message *&msg, Keys *keyData) override;

        #pragma region "START Mining Tool Bar"

    private:
        void MiningSelectAll_Click(std::any sender, EventArgs *e);

        void MiningSelectNone_Click(std::any sender, EventArgs *e);

        void MiningInvertSelection_Click(std::any sender, EventArgs *e);

        void MiningRemoveSelected_Click(std::any sender, EventArgs *e);

        void MiningHideRegion_Click(std::any sender, EventArgs *e);

        void MiningShowRegion_Click(std::any sender, EventArgs *e);

        void MiningFocusRegion_Click(std::any sender, EventArgs *e);

        void MiningFilter_SelectedIndexChanged(std::any sender, EventArgs *e);

        #pragma endregion "END Mining Tool Bar"

        #pragma region "START Respawn Tool Bar

        void RespawnsSelectAll_Click(std::any sender, EventArgs *e);

        void RespawnsSelectNone_Click(std::any sender, EventArgs *e);

        void RespawnsRemoveSelected_Click(std::any sender, EventArgs *e);

        void ResapwnsHideRegion_Click(std::any sender, EventArgs *e);

        void ResapwnsShowRegion_Click(std::any sender, EventArgs *e);

        void ResapwnsFocusRegion_Click(std::any sender, EventArgs *e);

        void RespawnsInvertSelection_Click(std::any sender, EventArgs *e);

        void RespawnsFilter_SelectedIndexChanged(std::any sender, EventArgs *e);

        #pragma endregion "END Respawn Tool Bar

        void RegionTabs_Selecting(std::any sender, TabControlCancelEventArgs *e);









        /// <summary>
        /// Required designer variable.
        /// </summary>
        System::ComponentModel::IContainer *components = nullptr;

        /// <summary>
        /// Clean up any resources being used.
        /// </summary>
        /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
    protected:
        void Dispose(bool disposing) override;

        #pragma region Windows Form Designer generated code

        /// <summary>
        /// Required method for Designer support - do not modify
        /// the contents of this method with the code editor.
        /// </summary>
    private:
        void InitializeComponent();

        #pragma endregion

        System::Windows::Forms::ToolStrip *Tool;
        System::Windows::Forms::ToolStripButton *SelectButton;
        System::Windows::Forms::ToolStripButton *AddButton;
        System::Windows::Forms::ToolStripButton *MoveButton;
        System::Windows::Forms::ToolStripButton *ResizeButton;
        Server::MirForms::Control::MapContainer *mapContainer1;
        System::Windows::Forms::PictureBox *MapImage;
        System::Windows::Forms::Splitter *splitter1;
        System::Windows::Forms::ToolStripLabel *toolStripLabel1;
        System::Windows::Forms::TabPage *tabPage2;
        System::Windows::Forms::Panel *RespawnPanel;
        System::Windows::Forms::ToolStrip *RespawnTools;
        System::Windows::Forms::TabPage *tabPage4;
        System::Windows::Forms::Panel *MiningPanel;
        System::Windows::Forms::ToolStrip *toolStrip2;
        System::Windows::Forms::ToolStripButton *MiningSelectAll;
        System::Windows::Forms::ToolStripButton *MiningSelectNone;
        System::Windows::Forms::TabControl *RegionTabs;
        System::Windows::Forms::ToolStrip *toolStrip1;
        System::Windows::Forms::ToolStripButton *MiningRemoveSelected;
        System::Windows::Forms::ToolStripButton *MiningHideRegion;
        System::Windows::Forms::ToolStripButton *MiningShowRegion;
        System::Windows::Forms::ToolStripButton *MiningFocusRegion;
        System::Windows::Forms::ToolStripButton *MiningInvertSelection;
        System::Windows::Forms::ToolStripSeparator *toolStripSeparator1;
        System::Windows::Forms::ComboBox *MiningFilter;
        System::Windows::Forms::ToolStripButton *EndFocus;
        System::Windows::Forms::ToolStripSeparator *FocusBreak;
        System::Windows::Forms::StatusStrip *statusStrip1;
        System::Windows::Forms::ToolStripStatusLabel *MapDetailsLabel;
        System::Windows::Forms::ToolStrip *toolStrip3;
        System::Windows::Forms::ToolStripButton *RespawnsRemoveSelected;
        System::Windows::Forms::ToolStripButton *ResapwnsHideRegion;
        System::Windows::Forms::ToolStripButton *ResapwnsShowRegion;
        System::Windows::Forms::ToolStripSeparator *toolStripSeparator2;
        System::Windows::Forms::ToolStripButton *ResapwnsFocusRegion;
        System::Windows::Forms::ComboBox *RespawnsFilter;
        System::Windows::Forms::ToolStripButton *RespawnsInvertSelection;
        System::Windows::Forms::ToolStripButton *RespawnsSelectAll;
        System::Windows::Forms::ToolStripButton *RespawnsSelectNone;
    };
}
